﻿
Partial Class m_descargaimgnotievento
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim imagen As String = Request.QueryString("img")
        Dim anio As String = DateTime.Now.Year()
        Dim mes As String = DateTime.Now.Month()
        Dim dia As String = DateTime.Now.Day()
        Dim hora As String = DateTime.Now.Hour()
        Dim min As String = DateTime.Now.Minute()
        Dim seg As String = DateTime.Now.Second()
        If Len(mes) = 1 Then
            mes = "0" + mes
        End If
        If Len(dia) = 1 Then
            dia = "0" + dia
        End If
        If Len(hora) = 1 Then
            hora = "0" + hora
        End If
        If Len(min) = 1 Then
            min = "0" + min
        End If
        If Len(seg) = 1 Then
            seg = "0" + seg
        End If
        If imagen <> "" And BuscarTexto(imagen, ".jpg") Then
            Response.Clear()
            Response.ContentType = "application/octet-stream"
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + anio + mes + dia + hora + min + seg + ".jpg") 'RENOMBRA IMAGEN
            Response.WriteFile("/imagenes_notieventos/" + imagen + "") 'LEE IMAGEN
            Response.End()
        End If
    End Sub
    Private Function BuscarTexto(ByVal Texto As String, ByVal Busqueda As String) As Boolean
        Dim i As Integer
        i = InStr(1, Texto, Busqueda)
        If i > 0 Then
            BuscarTexto = True
        Else
            BuscarTexto = False
        End If
    End Function
End Class
